package com.qingmeng.applyjob.portal.service.impl;

import com.github.pagehelper.PageHelper;
import com.qingmeng.applyjob.mapper.*;
import com.qingmeng.applyjob.model.*;
import com.qingmeng.applyjob.portal.enums.InterpolatingResult;
import com.qingmeng.applyjob.portal.enums.InterpolatingScheduleCode;
import com.qingmeng.applyjob.portal.model.dto.AskInterpolatingPublishParam;
import com.qingmeng.applyjob.portal.model.dto.HelpInterParam;
import com.qingmeng.applyjob.portal.model.dto.MessageToInterParam;
import com.qingmeng.applyjob.portal.model.vo.ChoosePusherVo;
import com.qingmeng.applyjob.portal.model.vo.InterpolatingListVo;
import com.qingmeng.applyjob.portal.model.vo.InterpolatingVo;
import com.qingmeng.applyjob.portal.model.vo.MyInterpolatingListVo;
import com.qingmeng.applyjob.portal.model.vo.voclass.ChoosePusher;
import com.qingmeng.applyjob.portal.model.vo.voclass.ProjectVo;
import com.qingmeng.applyjob.portal.service.InterpolatingService;
import com.qingmeng.applyjob.portal.utils.SecurityUtils;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class InterpolatingServiceImpl implements InterpolatingService {

    @Autowired
    private AskInterpolatingMapper askInterpolatingMapper;
    @Autowired
    private UserAskInterRelationMapper userAskInterRelationMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private EducationMapper educationMapper;
    @Autowired
    private ProjectMapper projectMapper;
    @Autowired
    private MessageToAskInterMapper messageToAskInterMapper;
    @Autowired
    private InterMessageRelationMapper interMessageRelationMapper;
    @Autowired
    private HelpInterpolatingMapper helpInterpolatingMapper;
    @Autowired
    private AskHelpRelationMapper askHelpRelationMapper;
    @Autowired
    private InterScheduleRelationMapper interScheduleRelationMapper;
    @Autowired
    private InterpolatingScheduleMapper interpolatingScheduleMapper;

    @Transactional
    @Override
    public InterpolatingResult publishAskInterpolating(AskInterpolatingPublishParam askInterpolatingPublishParam) {
        AskInterpolating askInterpolating = new AskInterpolating();
        askInterpolating.setTitle(askInterpolatingPublishParam.getTitle());
        askInterpolating.setPosition(askInterpolatingPublishParam.getPosition());
        askInterpolating.setIntroduce(askInterpolatingPublishParam.getIntroduce());
        askInterpolating.setMoney(askInterpolatingPublishParam.getMoney());
        askInterpolating.setCompany(askInterpolatingPublishParam.getCompany());
        askInterpolating.setCreateTime(new Date());
        //如果前端传来的标题为空，则返回 请输入标题
        if (askInterpolating.getTitle().length() == 0 || askInterpolating.getTitle() == null){
            return InterpolatingResult.WITHOUT_TITLE;
        }else{
            if (askInterpolatingMapper.insertSelective(askInterpolating) <= 0){
                return InterpolatingResult.FAILED;
            }else{
                UserAskInterRelation userAskInterRelation = new UserAskInterRelation();
                userAskInterRelation.setAskInterId(askInterpolating.getId());
                userAskInterRelation.setUserId(SecurityUtils.getCurrentUser().getId());
                if (userAskInterRelationMapper.insertSelective(userAskInterRelation) <= 0){
                    return InterpolatingResult.FAILED;
                }
            }
        }
        InterScheduleRelation interScheduleRelation = new InterScheduleRelation();
        interScheduleRelation.setInterId(askInterpolating.getId());
        interScheduleRelation.setScheduleId(InterpolatingScheduleCode.NOT_RESPONDING);
        if (interScheduleRelationMapper.insertSelective(interScheduleRelation) <= 0){
            return InterpolatingResult.FAILED;
        }
        return InterpolatingResult.SUCCESS;
    }

    @Transactional
    @Override
    public List<InterpolatingListVo> interpolatingList(int pageNum, int pageSize) {
        List<InterpolatingListVo> interpolatingListVos = new ArrayList<>();
        //根据内推条数进行分页
        PageHelper.startPage(pageNum,pageSize);
        AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
        List<AskInterpolating> askInterpolatings = askInterpolatingMapper.selectByExample(askInterpolatingExample);
        if (askInterpolatings != null && askInterpolatings.size() != 0){
            for (AskInterpolating askInterpolating : askInterpolatings){
                //获取每条求内推的状态  ， 状态为‘待确定’的才会显示在列表中
                InterScheduleRelationExample interScheduleRelationExample = new InterScheduleRelationExample();
                interScheduleRelationExample.createCriteria().andInterIdEqualTo(askInterpolating.getId());
                List<InterScheduleRelation> interScheduleRelations = interScheduleRelationMapper.selectByExample(interScheduleRelationExample);
                if (interScheduleRelations != null && interScheduleRelations.size() != 0){
                    Long id = interScheduleRelations.get(0).getScheduleId();
                    InterpolatingScheduleExample interpolatingScheduleExample = new InterpolatingScheduleExample();
                    interpolatingScheduleExample.createCriteria().andIdEqualTo(id);
                    List<InterpolatingSchedule> interpolatingSchedules = interpolatingScheduleMapper.selectByExample(interpolatingScheduleExample);
                    if (interpolatingSchedules != null && interpolatingSchedules.size() != 0){
                        if (interpolatingSchedules.get(0).getId() == InterpolatingScheduleCode.TO_BE_DETERMINED){
                            InterpolatingListVo interpolatingListVo = new InterpolatingListVo();
                            interpolatingListVo.setInterpolatingId(askInterpolating.getId());
                            interpolatingListVo.setTitle(askInterpolating.getTitle());
                            interpolatingListVo.setPosition(askInterpolating.getPosition());
                            interpolatingListVo.setIntroduce(askInterpolating.getIntroduce());
                            interpolatingListVo.setMoney(askInterpolating.getMoney());

                            //获取发布时间，将时间戳转换为正常时间
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                            String format = simpleDateFormat.format(askInterpolating.getCreateTime());
                            interpolatingListVo.setCreateTime(format);

                             //获取响应人数
                            int responders = 0;
                            AskHelpRelationExample askHelpRelationExample = new AskHelpRelationExample();
                            askHelpRelationExample.createCriteria().andAskInterIdEqualTo(askInterpolating.getId());
                            List<AskHelpRelation> askHelpRelations = askHelpRelationMapper.selectByExample(askHelpRelationExample);
                            if (askHelpRelations != null && askHelpRelations.size() > 0){
                                for (AskHelpRelation askHelpRelation : askHelpRelations){
                                    responders += 1;
                                }
                                interpolatingListVo.setResponders(responders);
                            }

                            //根据askInterpolating获取到userId
                            UserAskInterRelationExample userAskInterRelationExample = new UserAskInterRelationExample();
                            userAskInterRelationExample.createCriteria().andAskInterIdEqualTo(askInterpolating.getId());
                            List<UserAskInterRelation> userAskInterRelations = userAskInterRelationMapper.selectByExample(userAskInterRelationExample);
                            if (userAskInterRelations != null && userAskInterRelations.size() != 0){
                                Long userId = userAskInterRelations.get(0).getUserId();
                                //获取user表信息
                                UserExample userExample = new UserExample();
                                userExample.createCriteria().andIdEqualTo(userId);
                                List<User> users = userMapper.selectByExample(userExample);
                                if (users != null && users.size() != 0){
                                    interpolatingListVo.setAvatar(users.get(0).getAvatar());
                                    interpolatingListVo.setUsername(users.get(0).getUsername());
                                    //根据userId获取education表相关内容
                                    EducationExample educationExample = new EducationExample();
                                    educationExample.createCriteria().andUserIdEqualTo(userId);
                                    List<Education> educationList = educationMapper.selectByExample(educationExample);
                                    if (educationList !=null && educationList.size() != 0){
                                        interpolatingListVo.setSchool(educationList.get(0).getCollageName());
                                        interpolatingListVo.setSubject(educationList.get(0).getMajor());
                                        interpolatingListVo.setEducation(educationList.get(0).getEducation());
                                    }
                                    interpolatingListVos.add(interpolatingListVo);
                                }
                            }
                        }
                    }
                }
            }
        }
        return interpolatingListVos;
    }

    @Transactional
    @Override
    public InterpolatingVo getAskInterpolating(Long askInterpolatingId) {
        InterpolatingVo interpolatingVo = new InterpolatingVo();
        //根据 求内推id获取userId
        UserAskInterRelationExample userAskInterRelationExample = new UserAskInterRelationExample();
        userAskInterRelationExample.createCriteria().andAskInterIdEqualTo(askInterpolatingId);
        List<UserAskInterRelation> userAskInterRelations = userAskInterRelationMapper.selectByExample(userAskInterRelationExample);
        if (userAskInterRelations != null && userAskInterRelations.size() > 0) {
            Long userId = userAskInterRelations.get(0).getUserId();
            //根据userId获取user对象
            UserExample userExample = new UserExample();
            userExample.createCriteria().andIdEqualTo(userId);
            List<User> users = userMapper.selectByExample(userExample);
            User user = users.get(0);
            interpolatingVo.setUsername(user.getUsername());
            interpolatingVo.setGender(user.getGender());
            interpolatingVo.setAge(user.getAge());
            interpolatingVo.setUserIntroduce(user.getIntroduce());
            interpolatingVo.setUserId(userId);
            //根据userId获取education
            EducationExample educationExample = new EducationExample();
            educationExample.createCriteria().andUserIdEqualTo(userId);
            List<Education> educationList = educationMapper.selectByExample(educationExample);
            Education education = educationList.get(0);
            interpolatingVo.setEducation(education.getEducation());
            interpolatingVo.setSchool(education.getCollageName());
            interpolatingVo.setMajor(education.getMajor());
            //根据userId获取项目列表
            ProjectExample projectExample = new ProjectExample();
            projectExample.createCriteria().andUserIdEqualTo(userId);
            List<Project> projectList = projectMapper.selectByExample(projectExample);
            List<ProjectVo> projectVos = new ArrayList<>();
            if (projectList != null && projectList.size() > 0) {
                for (Project project : projectList) {
                    ProjectVo projectVo = new ProjectVo();
                    projectVo.setProjectName(project.getProjectName());
                    projectVo.setProjectPosition(project.getPosition());
                    projectVo.setProjectIntroduce(project.getIntroduce());
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM");
                    if (project.getStartTime() != null) {
                        String format = simpleDateFormat.format(project.getStartTime());
                        projectVo.setProjectStartTime(format);
                    } else {
                        projectVo.setProjectStartTime(null);
                    }
                    if (project.getEndTime() != null) {
                        String format = simpleDateFormat.format(project.getEndTime());
                        projectVo.setProjectEndTime(format);
                    } else {
                        projectVo.setProjectEndTime("至今");
                    }
                    projectVos.add(projectVo);
                }
            }
            interpolatingVo.setProjectList(projectVos);
            //根据userId获取askInterpolating表
            AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
            askInterpolatingExample.createCriteria().andIdEqualTo(askInterpolatingId);
            List<AskInterpolating> askInterpolatings = askInterpolatingMapper.selectByExample(askInterpolatingExample);
            AskInterpolating askInterpolating = askInterpolatings.get(0);
            interpolatingVo.setCompany(askInterpolating.getCompany());
            interpolatingVo.setPosition(askInterpolating.getPosition());
            interpolatingVo.setMoney(askInterpolating.getMoney());
            interpolatingVo.setInterIntroduce(askInterpolating.getIntroduce());
        }
        return interpolatingVo;
    }

    @Transactional
    @Override
    public int messageToInter(MessageToInterParam messageToInterParam) {
        MessageToAskInter messageToAskInter  = new MessageToAskInter();
        messageToAskInter.setMessage(messageToInterParam.getMessage());
        messageToAskInter.setUserId(SecurityUtils.getCurrentUser().getId());
        messageToAskInter.setCreateTime(new Date());
        if (messageToAskInterMapper.insertSelective(messageToAskInter) <= 0){
            return 0;
        }else{
            InterMessageRelation interMessageRelation = new InterMessageRelation();
            interMessageRelation.setAskInterpolatingId(messageToInterParam.getAskInterId());
            interMessageRelation.setMessageId(messageToAskInter.getId());
            if (interMessageRelationMapper.insertSelective(interMessageRelation) <= 0){
                return 0;
            }
        }
        return 1;
    }

    @Transactional
    @Override
    public int helpInter(HelpInterParam helpInterParam) {
        HelpInterpolating helpInterpolating = new HelpInterpolating();
        helpInterpolating.setCompany(helpInterParam.getCompany());
        helpInterpolating.setPosition(helpInterParam.getPosition());
        helpInterpolating.setMessage(helpInterParam.getMessage());
        helpInterpolating.setUserId(SecurityUtils.getCurrentUser().getId());
        helpInterpolating.setCreateTime(new Date());
        if (helpInterpolatingMapper.insertSelective(helpInterpolating) <= 0){
            return 0;
        }else {
            AskHelpRelation askHelpRelation = new AskHelpRelation();
            askHelpRelation.setAskInterId(helpInterParam.getAskInterId());
            askHelpRelation.setHelpInterId(helpInterpolating.getId());
            if (askHelpRelationMapper.insertSelective(askHelpRelation) <= 0){
                return 0;
            }
        }
        return 1;
    }

    @Transactional
    @Override
    public List<MyInterpolatingListVo> getMyNotRespondInterList(int pageNum, int pageSize) {
        List<MyInterpolatingListVo> myInterpolatingListVos = new ArrayList<>();
        //根据我的内推内推条数进行分页
        PageHelper.startPage(pageNum,pageSize);
        //根据当前userId获取到askInterId
        UserAskInterRelationExample u = new UserAskInterRelationExample();
        u.createCriteria().andUserIdEqualTo(SecurityUtils.getCurrentUser().getId());
        List<UserAskInterRelation> userAskInterRelations1 = userAskInterRelationMapper.selectByExample(u);
        if (userAskInterRelations1 != null && userAskInterRelations1.size() != 0){
            for (UserAskInterRelation uAIR : userAskInterRelations1){
                Long askInterId = uAIR.getAskInterId();
                AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
                askInterpolatingExample.createCriteria().andIdEqualTo(askInterId);
                List<AskInterpolating> askInterpolatings = askInterpolatingMapper.selectByExample(askInterpolatingExample);
                if (askInterpolatings != null && askInterpolatings.size() != 0){
                    AskInterpolating askInterpolating = askInterpolatings.get(0);
                        //获取每条求内推的状态  ， 状态为‘未响应’的才会显示在列表中
                        InterScheduleRelationExample interScheduleRelationExample = new InterScheduleRelationExample();
                        interScheduleRelationExample.createCriteria().andInterIdEqualTo(askInterpolating.getId());
                        List<InterScheduleRelation> interScheduleRelations = interScheduleRelationMapper.selectByExample(interScheduleRelationExample);
                        if (interScheduleRelations != null && interScheduleRelations.size() != 0){
                            Long id = interScheduleRelations.get(0).getScheduleId();
                            InterpolatingScheduleExample interpolatingScheduleExample = new InterpolatingScheduleExample();
                            interpolatingScheduleExample.createCriteria().andIdEqualTo(id);
                            List<InterpolatingSchedule> interpolatingSchedules = interpolatingScheduleMapper.selectByExample(interpolatingScheduleExample);
                            if (interpolatingSchedules != null && interpolatingSchedules.size() != 0){
                                if (interpolatingSchedules.get(0).getId() == InterpolatingScheduleCode.NOT_RESPONDING){
                                    MyInterpolatingListVo interpolatingListVo = new MyInterpolatingListVo();
                                    interpolatingListVo.setInterpolatingId(askInterpolating.getId());
                                    interpolatingListVo.setTitle(askInterpolating.getTitle());
                                    interpolatingListVo.setPosition(askInterpolating.getPosition());
                                    interpolatingListVo.setIntroduce(askInterpolating.getIntroduce());
                                    interpolatingListVo.setMoney(askInterpolating.getMoney());
                                    if (askInterpolating.getCreateTime() != null){
                                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日");
                                        String format = simpleDateFormat.format(askInterpolating.getCreateTime());
                                        interpolatingListVo.setCreateTime(format);
                                    }else{
                                        interpolatingListVo.setCreateTime(null);
                                    }
                                    //根据askInterpolating获取到userId
                                    UserAskInterRelationExample userAskInterRelationExample = new UserAskInterRelationExample();
                                    userAskInterRelationExample.createCriteria().andAskInterIdEqualTo(askInterpolating.getId());
                                    List<UserAskInterRelation> userAskInterRelations = userAskInterRelationMapper.selectByExample(userAskInterRelationExample);
                                    if (userAskInterRelations != null && userAskInterRelations.size() != 0){
                                        Long userId = userAskInterRelations.get(0).getUserId();
                                        //获取user表信息
                                        UserExample userExample = new UserExample();
                                        userExample.createCriteria().andIdEqualTo(userId);
                                        List<User> users = userMapper.selectByExample(userExample);
                                        if (users != null && users.size() != 0){
                                            interpolatingListVo.setAvatar(users.get(0).getAvatar());
                                            interpolatingListVo.setUsername(users.get(0).getUsername());
                                            //根据userId获取education表相关内容
                                            EducationExample educationExample = new EducationExample();
                                            educationExample.createCriteria().andUserIdEqualTo(userId);
                                            List<Education> educationList = educationMapper.selectByExample(educationExample);
                                            if (educationList !=null && educationList.size() != 0){
                                                interpolatingListVo.setSchool(educationList.get(0).getCollageName());
                                                interpolatingListVo.setSubject(educationList.get(0).getMajor());
                                                interpolatingListVo.setEducation(educationList.get(0).getEducation());
                                            }
                                            myInterpolatingListVos.add(interpolatingListVo);
                                        }
                                    }
                                }
                            }
                        }
                }
            }

        }
        return myInterpolatingListVos;
    }

    @Transactional
    @Override
    public InterpolatingResult changeMyInter(AskInterpolatingPublishParam askInterpolatingPublishParam , Long interId) {
        AskInterpolating askInterpolating = new AskInterpolating();
        askInterpolating.setTitle(askInterpolatingPublishParam.getTitle());
        askInterpolating.setPosition(askInterpolatingPublishParam.getPosition());
        askInterpolating.setIntroduce(askInterpolatingPublishParam.getIntroduce());
        askInterpolating.setMoney(askInterpolatingPublishParam.getMoney());
        askInterpolating.setCompany(askInterpolatingPublishParam.getCompany());
        askInterpolating.setUpdateTime(new Date());
        //根据interId进行更新
        AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
        askInterpolatingExample.createCriteria().andIdEqualTo(interId);
        //如果前端传来的标题为空，则返回 请输入标题
        if (askInterpolating.getTitle().length() == 0 || askInterpolating.getTitle() == null){
            return InterpolatingResult.WITHOUT_TITLE;
        }else{
            if (askInterpolatingMapper.updateByExampleSelective(askInterpolating,askInterpolatingExample) <= 0){
                return InterpolatingResult.UPDATE_FAILED;
            }
        }
        return InterpolatingResult.UPDATE_SUCCESS;
    }

    //可以优化，将这个做成一个函数包装
    @Transactional
    @Override
    public List<MyInterpolatingListVo> getMyToBeDeterminedInter(int pageNum, int pageSize) {
        List<MyInterpolatingListVo> myInterpolatingListVos = new ArrayList<>();
        //根据我的内推内推条数进行分页
        PageHelper.startPage(pageNum,pageSize);
        //根据当前userId获取到askInterId
        UserAskInterRelationExample u = new UserAskInterRelationExample();
        u.createCriteria().andUserIdEqualTo(SecurityUtils.getCurrentUser().getId());
        List<UserAskInterRelation> userAskInterRelations1 = userAskInterRelationMapper.selectByExample(u);
        if (userAskInterRelations1 != null && userAskInterRelations1.size() != 0){
            for (UserAskInterRelation uAIR : userAskInterRelations1){
                Long askInterId = uAIR.getAskInterId();
                AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
                askInterpolatingExample.createCriteria().andIdEqualTo(askInterId);
                List<AskInterpolating> askInterpolatings = askInterpolatingMapper.selectByExample(askInterpolatingExample);
                if (askInterpolatings != null && askInterpolatings.size() != 0){
                    AskInterpolating askInterpolating = askInterpolatings.get(0);
                    //获取每条求内推的状态  ， 状态为‘待确定’的才会显示在列表中
                    InterScheduleRelationExample interScheduleRelationExample = new InterScheduleRelationExample();
                    interScheduleRelationExample.createCriteria().andInterIdEqualTo(askInterpolating.getId());
                    List<InterScheduleRelation> interScheduleRelations = interScheduleRelationMapper.selectByExample(interScheduleRelationExample);
                    if (interScheduleRelations != null && interScheduleRelations.size() != 0){
                        Long id = interScheduleRelations.get(0).getScheduleId();
                        InterpolatingScheduleExample interpolatingScheduleExample = new InterpolatingScheduleExample();
                        interpolatingScheduleExample.createCriteria().andIdEqualTo(id);
                        List<InterpolatingSchedule> interpolatingSchedules = interpolatingScheduleMapper.selectByExample(interpolatingScheduleExample);
                        if (interpolatingSchedules != null && interpolatingSchedules.size() != 0){
                            if (interpolatingSchedules.get(0).getId() == InterpolatingScheduleCode.TO_BE_DETERMINED){
                                MyInterpolatingListVo interpolatingListVo = new MyInterpolatingListVo();
                                interpolatingListVo.setInterpolatingId(askInterpolating.getId());
                                interpolatingListVo.setTitle(askInterpolating.getTitle());
                                interpolatingListVo.setPosition(askInterpolating.getPosition());
                                interpolatingListVo.setIntroduce(askInterpolating.getIntroduce());
                                interpolatingListVo.setMoney(askInterpolating.getMoney());
                                if (askInterpolating.getCreateTime() != null){
                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日");
                                    String format = simpleDateFormat.format(askInterpolating.getCreateTime());
                                    interpolatingListVo.setCreateTime(format);
                                }else{
                                    interpolatingListVo.setCreateTime(null);
                                }
                                //根据askInterpolating获取到userId
                                UserAskInterRelationExample userAskInterRelationExample = new UserAskInterRelationExample();
                                userAskInterRelationExample.createCriteria().andAskInterIdEqualTo(askInterpolating.getId());
                                List<UserAskInterRelation> userAskInterRelations = userAskInterRelationMapper.selectByExample(userAskInterRelationExample);
                                if (userAskInterRelations != null && userAskInterRelations.size() != 0){
                                    Long userId = userAskInterRelations.get(0).getUserId();
                                    //获取user表信息
                                    UserExample userExample = new UserExample();
                                    userExample.createCriteria().andIdEqualTo(userId);
                                    List<User> users = userMapper.selectByExample(userExample);
                                    if (users != null && users.size() != 0){
                                        interpolatingListVo.setAvatar(users.get(0).getAvatar());
                                        interpolatingListVo.setUsername(users.get(0).getUsername());
                                        //根据userId获取education表相关内容
                                        EducationExample educationExample = new EducationExample();
                                        educationExample.createCriteria().andUserIdEqualTo(userId);
                                        List<Education> educationList = educationMapper.selectByExample(educationExample);
                                        if (educationList !=null && educationList.size() != 0){
                                            interpolatingListVo.setSchool(educationList.get(0).getCollageName());
                                            interpolatingListVo.setSubject(educationList.get(0).getMajor());
                                            interpolatingListVo.setEducation(educationList.get(0).getEducation());
                                        }
                                        myInterpolatingListVos.add(interpolatingListVo);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return myInterpolatingListVos;
    }

    @Transactional
    @Override
    public ChoosePusherVo choosePusher(Long interId) {
        ChoosePusherVo choosePusherVo = new ChoosePusherVo();
        //根据interId获取askInter表
        AskInterpolatingExample askInterpolatingExample = new AskInterpolatingExample();
        askInterpolatingExample.createCriteria().andIdEqualTo(interId);
        List<AskInterpolating> askInterpolatings = askInterpolatingMapper.selectByExample(askInterpolatingExample);
        if (askInterpolatings != null && askInterpolatings.size() > 0){
            AskInterpolating askInterpolating = askInterpolatings.get(0);
            choosePusherVo.setTitle(askInterpolating.getTitle());
            choosePusherVo.setPosition(askInterpolating.getPosition());
            choosePusherVo.setMoney(askInterpolating.getMoney());
            choosePusherVo.setIntroduce(askInterpolating.getIntroduce());
        }
        AskHelpRelationExample askHelpRelationExample = new AskHelpRelationExample();
        askHelpRelationExample.createCriteria().andAskInterIdEqualTo(interId);
        List<AskHelpRelation> askHelpRelations = askHelpRelationMapper.selectByExample(askHelpRelationExample);
        if (askHelpRelations != null && askHelpRelations.size() > 0){
            List<ChoosePusher> choosePusherList = new ArrayList<>();
            for (AskHelpRelation askHelpRelation : askHelpRelations){
                ChoosePusher choosePusher = new ChoosePusher();
                //根据interId获取userId
                    Long userId = SecurityUtils.getCurrentUser().getId();
                    //根据userId获取到user对象
                    UserExample userExample = new UserExample();
                    userExample.createCriteria().andIdEqualTo(userId);
                    List<User> users = userMapper.selectByExample(userExample);
                    if (users != null && users.size() > 0){
                        User user = users.get(0);
                        choosePusher.setUserId(user.getId());
                        choosePusher.setUsername(user.getUsername());
                        choosePusher.setSuccessRate(user.getSuccessRate());
                        choosePusher.setFavorableRate(user.getFavorableRate());
                        choosePusher.setAvatar(user.getAvatar());
                    }
                    //获取helpInterId
                        Long helpInterId = askHelpRelation.getHelpInterId();
                        //根据helpInterId获取到helpInter表
                        HelpInterpolatingExample helpInterpolatingExample = new HelpInterpolatingExample();
                        helpInterpolatingExample.createCriteria().andIdEqualTo(helpInterId);
                        List<HelpInterpolating> helpInterpolatings = helpInterpolatingMapper.selectByExample(helpInterpolatingExample);
                        if (helpInterpolatings != null && helpInterpolatings.size() > 0){
                            HelpInterpolating helpInterpolating = helpInterpolatings.get(0);
                            choosePusher.setCompany(helpInterpolating.getCompany());
                            choosePusher.setPosition(helpInterpolating.getPosition());
                            choosePusher.setMessage(helpInterpolating.getMessage());
                        }
                       choosePusherList.add(choosePusher);
            }
            choosePusherVo.setChoosePusherList(choosePusherList);
        }
        return choosePusherVo;
    }
}
